package com.qys.livesMall.open.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qys.livesMall.open.mapper.H2AppUserDeviceMapper;
import com.qys.livesMall.open.modal.dto.app.H2AppUserDeviceDTO;
import com.qys.livesMall.open.modal.entity.H2AppUserDevice;
import com.qys.livesMall.open.service.H2AppUserDeviceService;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户和设备关联表 服务实现类
 * </p>
 *
 * @author wzy
 * @since 2023-07-07
 */
@Service
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class H2AppUserDeviceServiceImpl extends ServiceImpl<H2AppUserDeviceMapper, H2AppUserDevice> implements H2AppUserDeviceService {

    @Resource
    private H2AppUserDeviceMapper h2AppUserDeviceMapper;
    /**
     * 保存用户和设备关联
     * @param dto
     */
    @Override
    public void saveUserDevice(H2AppUserDeviceDTO dto) {
        H2AppUserDevice h2AppUserDevice=new H2AppUserDevice();
        BeanUtils.copyProperties(dto,h2AppUserDevice);
        saveOrUpdate(h2AppUserDevice);
    }

    @Override
    public List<H2AppUserDevice> getByIds(List<Long> userIds, String code) {
        return h2AppUserDeviceMapper.getByIds(userIds,code);
    }
}
